import {ModalForm, ProFormSelect, ProFormText} from '@ant-design/pro-components';


export interface FormValueType extends Partial<API.MenuAlter> {
    target?: string;
    template?: string;
    time?: string;
    frequency?: string;
}


export interface EditFormProps {
    onOpenChange: (flag?: boolean, formVals?: FormValueType) => void;
    onSubmit: (values: FormValueType) => Promise<void>;
    editModalVisible: boolean;
    values: Partial<API.MenuAlter>;
    statusValueEnum?: Partial<Record<string, { text: string; type: string }>>;
    typeValueEnum?: Partial<Record<string, { text: string; type: string }>>;
}


export default (props: EditFormProps) => {
    return (
        <ModalForm
            title="编辑菜单"
            open={props.editModalVisible}
            onOpenChange={props.onOpenChange}
            onFinish={props.onSubmit}
            initialValues={props.values}
        >
            <ProFormText
                width="md"
                name="id"
                label="Id"
                hidden={true}
                disabled={true}
            />
            <ProFormText
                width="md"
                name="code"
                label="菜单Code"
                disabled={true}
            />
             <ProFormText
                width="md"
                name="parentCode"
                label="父菜单Code"
                hidden={true}
                disabled={true}
            />
            <ProFormText
                name="name"
                width="md"
                label="名称"
                rules={[
                    {required: true, message: '请输入名称'},
                ]}
            />
            <ProFormText
                name="component"
                width="md"
                label="菜单组件"
            />
            <ProFormText
                name="icon"
                width="md"
                label="菜单图标"
            />
            <ProFormText
                name="router"
                width="md"
                label="菜单路由"
            />
            <ProFormSelect
                width="md"
                name="status"
                label="节点状态"
                valueEnum={props.statusValueEnum}
                rules={[{required: true, message: '请输入节点状态'}]}
            />
          <ProFormSelect
                width="md"
                name="type"
                label="类型"
                valueEnum={props.typeValueEnum}
                rules={[{required: true, message: '请输入类型'}]}
            />

        </ModalForm>
    );
};
